//
//  BHCoacheModel.swift
//  BigHealth
//
//  Created by 布丁 on 2021/8/2.
//

import UIKit

class BHCoacheModel {
    var coachId: String = ""
    var name: String = ""
    var imageUrl: String = ""
    var introduce: String = ""

    func parseDic(_ dic: [String: Any])  {
        self.coachId = BHJsonTool.decodeStringFromDic(dic: dic, key: "id")
        self.name = BHJsonTool.decodeStringFromDic(dic: dic, key: "name")
        self.imageUrl = BHJsonTool.decodeStringFromDic(dic: dic, key: "iamgeUrl")
        self.introduce = BHJsonTool.decodeStringFromDic(dic: dic, key: "introduce")
    }
}

class BHCoachDetailModel {
    var coachId: String = ""
    var name: String = ""
    var imageUrl: String = ""
    var venueId: String = "" // 球馆id
    var introduce: String = "" // 教练介绍
    var courseIntroduce: String = "" // 课程介绍
    var contactNumber: String = "" // 联系电话
    var contacts: String = "" // 联系人
    var backRule: String = "" // 退改规则
    var discount: String = "" // 折扣
    var price: String = "" // 价格

    var images: [String] = []
    
    var buyNumber: Int = 0 // 购买次数

    func parseDic(_ dic: [String: Any])  {
        self.coachId = BHJsonTool.decodeStringFromDic(dic: dic, key: "id")
        self.name = BHJsonTool.decodeStringFromDic(dic: dic, key: "name")
        self.imageUrl = BHJsonTool.decodeStringFromDic(dic: dic, key: "iamgeUrl")
        self.introduce = BHJsonTool.decodeStringFromDic(dic: dic, key: "introduce")
        self.venueId = BHJsonTool.decodeStringFromDic(dic: dic, key: "venueId")
        self.courseIntroduce = BHJsonTool.decodeStringFromDic(dic: dic, key: "courseIntroduce")
        self.contactNumber = BHJsonTool.decodeStringFromDic(dic: dic, key: "contactNumber")
        self.contacts = BHJsonTool.decodeStringFromDic(dic: dic, key: "contacts")
        self.backRule = BHJsonTool.decodeStringFromDic(dic: dic, key: "backRule")
        self.discount = BHJsonTool.decodeStringFromDic(dic: dic, key: "discount")
        self.price = BHJsonTool.decodeStringFromDic(dic: dic, key: "price")

        self.buyNumber = BHJsonTool.decodeIntFromDic(dic: dic, key: "buyNumber")
        
        let array = BHJsonTool.decodeArrayFromDic(dic: dic, key: "images")
        if self.images.count != 0 {
            self.images.removeAll()
        }
        
        for item in array {
            if item is NSNull {
                continue
            }else {
                self.images.append(item as! String)
            }
        }
        
    }
}
